<?php

/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/1/12
 * Time: 10:29
 */
class StudentService
{

    const GRADUATION_MONETH = 8;
    //判断在读年级
    //return:Array('2017'=>"六年级",'2018','2019','2020','2021','2022')
    public static function getInGrade():array
    {
        $nowyear = date("Y", time());
        $nowmonty = date("m", time());
        $graduation_month = self::GRADUATION_MONETH;
        if ($nowmonty >= $graduation_month) {//大于等于9月，应届的已经毕业，小一届的升级
            $nowyear += 1;
        }
        $greadStrArr = array("六年级", "五年级", "四年级", "三年级", "二年级", "一年级");
        $greadArr = array();
        foreach ($greadStrArr as $k => $v) {
            $greadArr[$nowyear + $k] = $v;
        }
        return $greadArr;
    }

    //返回当前六年级的届数
    public static function graduationBeginYear():int
    {
        $nowyear = date("Y", time());
        $nowmonty = date("m", time());
        $graduation_month = self::GRADUATION_MONETH;
        if ($nowmonty >= $graduation_month) {
            $nowyear += 1;
        }
        return $nowyear;
    }
}